<?php include $this->getViewFile('/common/Head'); ?>
<body class="J_scroll_fixed">
<style>
.product_img img {
    border:solid 3px #fff;
    margin-right:5px;
}
.product_img img.hover {
    border-color:#ff8800;
}
.product_img img.current {
    border-color:#df0001;
}
</style>
<div class="wrap J_check_wrap">
   <?php include $this->getViewFile('/common/Nav') ?>
   <form class="J_ajaxForm" action="<?php echo AdminBase::U("add") ?>" method="post" id="myform">
   <div class="h_a">基本属性</div>
   <div class="table_full">
   <table width="100%" class="table_form contentWrap">
        <tbody>
          <tr>
            <th width="80">URL</th>
            <td><input type="test" name="detail_url" class="input length_6" id="detail_url" value=""></td>
          </tr>
          <tr>
            <th>商品ID</th>
            <td><input type="text" name="product_id" class="input length_6" value=""></td>
          </tr>
          <tr>
            <th>商品标题</th>
            <td><input type="text" name="goods_name" value="" class="input length_6" id="goods_name"></td>
          </tr>
          <tr>
            <th>商品分类</th>
            <td><select name="cat_id">
                    <option value="">请选择商品分类</option>
                    <?php echo CategoryModel::model()->htmlCategorySelectOption(0) ?>
                    </select></td>
          </tr>
          <tr>
            <th>商品品牌</th>
            <td><?php echo Form::select(BrandModel::model()->getBrandArray(),0,'name="brand_id"','请选择品牌'); ?></td>
          </tr>
          <tr>
            <th>商品原价</th>
            <td><input type="text" name="p_price" class="input length_1" value=""></td>
          </tr>
          <tr>
            <th>活动价格</th>
            <td><input type="text" name="promo_price" class="input length_1" value="0" id="promo_price"> <input type="checkbox" name="is_vip"  value="1"> <em>是设置的VIP价格</em> </td>
          </tr>
         <tr>
          <th>销量</td>
          <td><input type="text" name="sales" class="input length_1" value="0" id="sales"> <em>目前的最新销量</em></td>
         </tr>
         <tr>
          <th>卖家包邮</td>
          <td><?php echo Form::radio(array(1=>'免运费',0=>'不免运费'),1,'name="freeshipping"'); ?></td>
         </tr>
         <tr>
          <th>报名数量</td>
          <td><input type="text" name="stock" class="input length_1" value="0"> <span class="gray">件</span></td>
         </tr>
         <tr>
          <th>是否展示</td>
          <td><?php echo Form::radio(array(1=>'上架',0=>'下架'),1,'name="status"'); ?></td>
         </tr>
         <tr>
          <th>商品预告</td>
          <td><?php echo Form::radio(array(0=>'正常预告',1=>'不进行预告'),0,'name="isyugao"'); ?></td>
         </tr>
         <tr>
          <th>上架时间</td>
          <td><input type="text" name="start_time" class="input length_2 J_datetime " value="<?php echo  date('Y-m-d 10:00')?>" placeholder="上架时间"></td>
         </tr>
         <tr>
          <th>下架时间</td>
          <td><input type="text" name="end_time" class="input length_2 J_datetime " value="<?php echo  date('Y-m-d 10:00',(time()+(3*86400)))?>" placeholder="下架时间"></td>
         </tr>
         <tr>
          <th>所在地</td>
          <td>
            <input type="text" name="state" class="input length_2" value="" />
            <input type="text" name="city" class="input length_2" value="" />
          </td>
         </tr>
         <tr>
          <th>商品图片</td>
          <td><input type="text" name="product_img" value="" class="input" id="product_img" style="width:500px"></td>
         </tr>
         <tr>
          <th></td>
          <td>
          <div class="product_img">
          </div></td>
         </tr>
         <tr>
          <th>推荐理由</td>
          <td><textarea type="text" name="goods_brief" cols="60" rows="6"></textarea></td>
         </tr>
         <tr>
          <th>扩展属性</td>
          <td><input type="checkbox" name="is_best"  value="1"> 推荐 <input type="checkbox" name="is_new" value="1"> 新品 <input type="checkbox" name="is_hot" value="1"> 热卖 <input type="checkbox" name="is_stock" value="1"> 已售完</td>
         </tr>
         <tr>
          <th>Level</td>
          <td><?php echo Form::select(CustomBlockModel::model()->getLevelArray(),0,'name="level"'); ?></td>
         </tr>
         <tr>
          <th>商品排序</td>
          <td><input type="text" name="listorder" class="input length_1" value=""></td>
         </tr>
        </tbody>
      </table>
   </div>
   <div class="btn_wrap">
      <div class="btn_wrap_pd">
		<input type="hidden" name="nick" value="京东商品" />
		<input type="hidden" name="item_type" value="11" />
        <button class="btn btn_submit mr10 J_ajax_submit_btn" type="submit">确认添加</button>
      </div>
    </div>
    </form>
</div>
<script src="<?php echo $staticUrl; ?>statics/js/common.js"></script>
<script>
function product_img(){
	$('div.product_img img').click(function() {
		$('div.product_img img').removeClass('current');
		$(this).addClass('current');
		$('#product_img').val(this.src);
    });
}
$(function(){
	//点击图片
	if($('div.product_img img').length){
		product_img();
	}
	if($('button.J_ajax_getiteminfo').length){
		$('button.J_ajax_getiteminfo').click(function(){
			var but = this;
			var text = $(but).text();
			//var product_id = $(this).data('product_id');
			var product_id = $('input[name="detail_url"]').val();
			$(but).text('获取中...');
			$.getJSON('<?php echo AdminBase::U("goodsbm/public_iteminfo") ?>',{product_id:product_id},function(data){
				$(but).text(text);
				if(data.status){
					//商品地址
					$('#detail_url').val(data.detail_url);
					$('#goods_name').val(data.title);
					//原价
					$('#p_price').html(data.p_price);
					$('input[name="p_price"]').val(data.p_price);
					//商品ID
					$('#product_id').html(data.product_id);
					$('input[name="product_id"]').val(data.product_id);
					//店铺类型
					$('input[name="item_type"]').val(data.item_type);
					//活动价
					$('input[name="promo_price"]').val(data.promo_price);
					//销量
					if(data.item_type==0){
						$('#sales').val(data.sales);
					}
					//商品地址
					$('.detail_url').val(data.detail_url);
					//地区
					$('.state').html(data.province);
					$('input[name="state"]').val(data.province);
					$('.city').html(data.city);
					$('input[name="city"]').val(data.city);
					//旺旺
					$('input[name="nick"]').val(data.nick);
					
					//图片
					var imgstr = '';
					if (data.images) {
						$.each(data.images,function(i,v){
							if(i == 0){
								$('#product_img').val(v);
								imgstr += '<img class="current" width="160" height="160" src=' + v + ' />';
							}else{
								 imgstr += '<img  width="160" height="160"  src=' + v + ' />';
							}
						});
						$('div.product_img').html(imgstr);
						product_img();
					}
				}
			});
			return false;
		});
	}
});
</script>
</body>
</html>